<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <script>
      class Animal {
        constructor(kemu, color) {
          this.kemu = kemu
          this.color = color
        }
        eat() {
          console.log(this.kemu + '吃')
        }
      }
      //es6 的继承
      // 1) class 子类 extends 父类{}
      // 2) 必须在构造器中 调用super()
      // 3) 在super(参数，参数)给父类传递的参数
      class Cat extends Animal {
        constructor(name, age) {
          super('猫科', '黑色') //必须调用 而且可以给父类传参
          this.name = name
          this.age = age
        }
        run() {
          console.log('跑')
        }
      }
      //
      let kitimao = new Cat('kitty猫', 4)
      kitimao.run()
      kitimao.eat()
    </script>
  </body>
</html>
